package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(20);not null;comment:'账号'"`
	Password string `gorm:"type:char(32);not null;comment:'密码'"`
	Mobile   string `gorm:"type:char(11);not null;comment:'手机号'"`
}

type Popularity struct {
	gorm.Model
	Name  string  `gorm:"type:varchar(20);not null;comment:'人气名称'"`
	Desc  string  `gorm:"type:varchar(50);not null;comment:'描述'"`
	Price float64 `gorm:"type:decimal(10,2);not null;comment:'价格'"`
	Img   string  `gorm:"type:varchar(500);not null;comment:'图片'"`
}

type Shop struct {
	gorm.Model
	Name   string  `gorm:"type:varchar(20);not null;comment:'商品名称'"`
	Price  float64 `gorm:"type:decimal(10,2);not null;comment:'价格'"`
	Stroll string  `gorm:"type:varchar(20);not null;comment:'在逛人数'"`
	Coupon string  `gorm:"type:varchar(30);not null;comment:'优惠券'"`
	Img    string  `gorm:"type:varchar(500);not null;comment:'图片'"`
}

type Shopping struct {
	gorm.Model
	Name  string  `gorm:"type:varchar(20);not null;comment:'商品名称'"`
	Desc  string  `gorm:"type:varchar(30);not null;comment:'描述'"`
	Price float64 `gorm:"type:decimal(10,2);not null;comment:'价格'"`
	Stock int     `gorm:"type:int;not null;comment:'库存'"`
}

func (s *Shopping) GetShoppingBy(id int) error {
	return DB.Debug().Where("id = ?", id).Limit(1).Find(&s).Error
}
